﻿/*
* class GSoundGroup
* Creates GSound Instances under a group name
* with a parent MovieClip. Good to load some
* Samples via loadMovie
*/

import com.audiopackage.GSound;
import com.audiopackage.GTargetClipSupplier;

class com.audiopackage.GSoundGroup
	implements com.gamepackage.util.Loadable
{
	static private var instances: Object = new Object();
	
	private var timeline: MovieClip;
	private var gSoundCount: Number;
	
	static function getInstanceByName( name: String ): GSoundGroup
	{
		return instances[ name ];
	}
	
	function GSoundGroup( name: String, parent: MovieClip )
	{
		if ( parent == undefined )
		{
			timeline = GTargetClipSupplier.getTargetClip();
		}
		else
		{
			this.timeline = parent.createEmptyMovieClip( name , parent.getNextHighestDepth() );
		}
		
		instances[ name ] = this;

		gSoundCount = 0;
	}
	
	function getNewGSound( linkageId: String ): GSound
	{
		var targetClip: MovieClip = timeline.createEmptyMovieClip( '_tc_' + gSoundCount , gSoundCount++ );
		
		return new GSound( targetClip ).attachSound( linkageId );
	}
	
	function getLoaderClip( Void ): MovieClip
	{
		return timeline;
	}
}